package org.django4j;

import java.lang.reflect.Method;
import java.util.regex.Pattern;

public class UrlMapping {
    private String regexp;
    /** the url regular expression, compiled style */
    private Pattern pattern;
    /** the instance of controller class handling a specific request */
    private Class controller;
    /** the method of controller class handling a specific request */
    private Method controllerMethod;
    
    public UrlMapping(String regexp, Pattern pattern, Class controller, Method method){
        this.regexp = regexp;
        this.pattern = pattern;
        this.controller = controller;
        this.controllerMethod = method;
    }
    
    public Pattern getPattern() {
        return pattern;
    }

    public String getRegexp() {
        return regexp;
    }
    
    public Class getController() {
        return controller;
    }
    
    public Method getControllerMethod() {
        return controllerMethod;
    }
    
    public String toString(){
        StringBuffer buffer = new StringBuffer();
        buffer.append("(regexp=").append(this.regexp).append(",");
        buffer.append("pattern=").append(pattern).append(",");
        buffer.append("controller=").append(controller.getName()).append(",");
        buffer.append("method=").append(controllerMethod.getName()).append(")");
        return buffer.toString();
    }
}
